// pages/wode/index.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    userInfo:{},
    gnList:[
      {name:'订单详情',img:'../../static/wode/ddxq.png',url:'/pages/myOrder/index'},
      {name:'公司介绍',img:'../../static/wode/gsjs.png',url:'/pages/introduce/index'},
      {name:'客服投诉',img:'../../static/wode/kfts.png',url:''},
      {name:'评价',img:'../../static/wode/pj.png',url:'/pages/comment/index'},
      {name:'隐私协议',img:'../../static/wode/ysxy.png',url:'/pages/privacyAgreement/index'},
      {name:'商家入驻',img:'../../static/wode/sjrz.png',url:'/pages/settleIn/index'},
      {name:'关于我们',img:'../../static/wode/gywm.png',url:'/pages/weAbout/index'}
    ],
    order:[
      {name:'未付款',img:'/images/user/dyy_icon.png',url:'/pages/myOrder/index?type=2'},
      {name:'已付款',img:'/images/user/dsy_icon.png',url:'/pages/myOrder/index?type=3'},
      {name:'待核销',img:'/images/user/ywc_icon.png',url:'/pages/myOrder/index?type=4'},
      {name:'已核销',img:'/images/user/hx_icon.png',url:'/pages/myOrder/index?type=5'},
    ],
    fuli:[
      {name:'精品微课',img:'/images/user/course_icon.png',url:''},
     
    ],
    service:[
      {name:'在线客服',img:'/images/user/kf_icon.png',url:''},
      //{name:'消息中心',img:'/images/user/xx_icon.png',url:''},
      {name:'设置',img:'/images/user/set_icon.png',url:'/pages/wode/set/index'},
    
    ],
    height: app.globalData.navHeight,
    topHeight: app.globalData.height,
    navContentHeight:app.globalData.navContentHeight,
    navContentWidth:app.globalData.navContentWidth,
  },
  // gotsss(){
  //   wx.navigateTo({
  //     url: '/pages/DaYinJi/DaYinJi',
  //   })
  // },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    wx.hideShareMenu()
    console.log(1)
   
  },
  onShow(){
    console.log(2)
    var userLogin=wx.getStorageSync('userLogin')
    if(userLogin.mobile){
      this.init()
    }else{
      wx.redirectTo({
        url: '/pages/login/index',
      })
    }
    
  },
  init(){
    let data = {
      id:wx.getStorageSync('userLogin').userId
    }
    app.agriknow.userHome(data).then(res=>{
      console.log(res)
      this.setData({
        userInfo:res.data
      })
     // wx.setStorageSync('userInfo',res.data)
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },
  /**
   * 生命周期函数--监听页面显示
   */
  
  gotoBalance(){
    wx.navigateTo({
      url: '/pages/lookBalance/index',
    })
  },
  gotobalaRecharge(){
    wx.navigateTo({
      url: '/pages/balanceRecharge/index',
    })
  },
  gotobalaWithdrawal(){
    wx.navigateTo({
      url: '/pages/balaWithdrawal/index',
    })
  },
  gotoGameCoin(){
    wx.navigateTo({
      url: '/pages/gameCoin/index',
    })
  },
  goHome(e){
    let index = e.currentTarget.dataset.index
    if(index==0){
      wx.navigateTo({
        url: '/pages/myOrder/index',
      })
    }
    if(index==1){
      wx.navigateTo({
        url: '/pages/introduce/index',
      })
    }
    if(index==3){
      wx.navigateTo({
        url: '/pages/comment/index',
      })
    }
    if(index==4){
      wx.navigateTo({
        url: '/pages/privacyAgreement/index',
      })
    }
    if(index==5){
      wx.navigateTo({
        url: '/pages/settleIn/index',
      })
    }
    if(index==6){
      wx.navigateTo({
        url: '/pages/weAbout/index',
      })
    }
  },
  toLink:function(e){
    var url=e.currentTarget.dataset.url
    if(url){
      if(url=='/pages/follow/index'){
     
        wx.switchTab({
          url: url,
        })
      }else{
        wx.navigateTo({
          url: url,
        })
      }
     
    }else{
      wx.showToast({
        title: '敬请期待',
        icon:'none',
        duration:1500,
      })
    }
   
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})